﻿using Competition.Application.Interfaces;
using Competition.Domain;
using Competition.Repository;
using Microsoft.EntityFrameworkCore;

namespace Competition.Application
{
    public class BaseService<TAggregateRoot> : IBaseService<TAggregateRoot> where TAggregateRoot : class, IAggregateRoot
    {
        protected readonly IDbContext DbContext;
        public BaseService(AppDbContext dbContext)
        {
            DbContext = dbContext;
        }

        public BaseRepository<TEntity> GetService<TEntity>() where TEntity : class, IAggregateRoot
        {

            return (BaseRepository<TEntity>)RepositoryFactory.CreateObj<TEntity>((AppDbContext)DbContext);
        }
    }
}